package com.example.springboot_demo.controller;

import com.example.springboot_demo.model.Alarm;
import com.example.springboot_demo.service.AlarmService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;


/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 文
 * @Date: 2024/11/28
 * @Time: 10:57
 * To change this template use File | Settings | File Templates.
 * @Description:
 */
@RestController
@RequestMapping("/alarms")
public class AlarmController {

    private static final Logger logger = LoggerFactory.getLogger(AlarmController.class);
    @Autowired
    private AlarmService alarmService;

    @PostMapping("/list")
    public ArrayList<Alarm> getAlarmList() {
        return alarmService.getAlarmList();
    }

    @PutMapping("/update/{id}")
    public void updateAlarm(@PathVariable("id") String id, @RequestBody Alarm alarm) {
        alarm.setAlarm_code(id);
        logger.info(alarm.toString());
        alarmService.updateAlarm(alarm);
    }
    }
